<?php
// +----------------------------------------------------------------------
// | LuluCWS [ Lulu COMPANY WEB SHOW]
// +----------------------------------------------------------------------
// | Copyright (c) 2010 http://www.luluui.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: uuleaf <uuleaf@163.com>
// +----------------------------------------------------------------------
class OrderformModel extends IrelaModel {
	/**
	 +----------------------------------------------------------
	 * 关联设置
	 +----------------------------------------------------------
	 * @access public
	 +----------------------------------------------------------
	 * @param none
	 +----------------------------------------------------------
	 * @return none
	 +----------------------------------------------------------
	 * @throws none
	 +----------------------------------------------------------
	 */
	protected $_link = array (
		'good' => array (
			'mapping_type' => HAS_MANY,
			'class_name' => 'Orderform_good',
			'foreign_key' => 'orderform_id',
			'mapping_name' => 'good',
		),
		'note' => array (
			'mapping_type' => HAS_MANY,
			'class_name' => 'Orderform_note',
			'foreign_key' => 'orderform_id',
			'mapping_name' => 'note',
			'mapping_order' => 'created desc',
		),
		'member' => array (
			'mapping_type' => BELONGS_TO,
			'class_name' => 'Member',
			'foreign_key' => 'member_id',
		)
	);
	/**
	 +----------------------------------------------------------
	 * 字段设置数组
	 +----------------------------------------------------------
	 * @access public
	 +----------------------------------------------------------
	 * @param none
	 +----------------------------------------------------------
	 * @return none
	 * '字段名称' => array();
	 * t 字体类型 ：input text function select relation
	 * v 默认值
	 +----------------------------------------------------------
	 * @throws ThinkExecption
	 +----------------------------------------------------------
	 */

	public $fields_set = array (
		'orderform_id' => array (
			't' => 'input',
			'v' => 0
		),
		'member_id' => array (
			't' => 'input',
			'v' => ''
		),
		'code' => array (
			't' => 'input',
			'v' => ''
		),
		'pay_type' => array (
			't' => 'input',
			'v' => 1
		),
		'express_type' => array (
			't' => 'input',
			'v' => ''
		),
		'express_code' => array (
			't' => 'input',
			'v' => ''
		),
		'consignee' => array (
			't' => 'input',
			'v' => ''
		),
		'consignee_addr' => array (
			't' => 'input',
			'v' => ''
		),         
		'consignee_phone' => array (
			't' => 'input',
			'v' => ''
		),
		'consignee_tel' => array (
			't' => 'input',
			'v' => ''
		),
		'zipcode' => array (
			't' => 'input',
			'v' => ''
		),
		'is_self' => array (
			't' => 'input',
			'v' => 1
		),
		'self_name' => array (
			't' => 'input',
			'v' => ''
		),
		'freight_fee' => array ( //运费价格
			't' => 'input',
			'v' => ''
		),
		'discount_fee' => array ( //折扣价格
			't' => 'input',
			'v' => ''
		),
		'total_fee' => array ( //商品价格
			't' => 'input',
			'v' => ''
		),
		'final_fee' => array (//最终价格
			't' => 'input',
			'v' => ''
		),
		'detail' => array (
			't' => 'input',
			'v' => ''
		),
		'note' => array (
			't' => 'input',
			'v' => ''
		),
		'progress' => array (
			't' => 'input',
			'v' => ''
		),
		'is_comment' => array (
			't' => 'input',
			'v' => 0
		),
		'happen' => array (
			't' => 'input',
			'v' => ''
		),
		'pay_time' => array (
			't' => 'input',
			'v' => ''
		),
		'delivery_time' => array (
			't' => 'input',
			'v' => ''
		),
		'cancel_time' => array (
			't' => 'input',
			'v' => ''
		),
		'complete_time' => array (
			't' => 'input',
			'v' => ''
		),
		'turnoff_time' => array (
			't' => 'input',
			'v' => ''
		),
		'divide_id' => array (
			't' => 'input',
			'v' => 0
		),
		'is_divide' => array (
			't' => 'input',
			'v' => 0
		),
		'created' => array (
			't' => 'function',
			'v' => 'time'
		),
		'changed' => array (
			't' => 'function',
			'v' => 'time'
		),
		'status' => array (
			't' => 'select',
			'v' => 1
		),
		'grade' => array (
			't' => 'select',
			'v' => 1
		),
		'oid' => array (
			't' => 'input',
			'v' => ''
		),
		//id orderform_id good_id good_code good_name good_img good_attr good_num good_price total_fee discount
		'good' => array (
			't' => 'relation_many',
			'mpk' => 'id',
			'oid' => 'good_name',
			'v' => array (
				'orderform_id' => array (
					't' => 'input',
					'v' => ''
				),
				'good_id' => array (
					't' => 'input',
					'v' => ''
				),
				'good_code' => array (
					't' => 'input',
					'v' => ''
				),
				'good_name' => array (
					't' => 'input',
					'v' => ''
				),
				'good_img' => array (
					't' => 'input',
					'v' => ''
				),
				'good_attr' => array (
					't' => 'input',
					'v' => ''
				),
				'good_price' => array (
					't' => 'input',
					'v' => ''
				),
				'total_fee' => array (
					't' => 'input',
					'v' => ''
				),
				'discount' => array (
					't' => 'input',
					'v' => 0
				)
			)
		),
		
	);
	/**
	 +----------------------------------------------------------
	 * 自动验证
	 +----------------------------------------------------------
	 * @access protected
	 +----------------------------------------------------------
	 * @param none
	 +----------------------------------------------------------
	 * @return none
	 +----------------------------------------------------------
	 * @throws none
	 +----------------------------------------------------------
	 */
	protected $_validate = array ();
	/**
	 +----------------------------------------------------------
	 * 自动填充
	 +----------------------------------------------------------
	 * @access protected
	 +----------------------------------------------------------
	 * @param none
	 +----------------------------------------------------------
	 * @return none
	 +----------------------------------------------------------
	 * @throws none
	 +----------------------------------------------------------
	 */
	protected $_auto = array (
		array (
			'status',
			'1'
		),
		// 新增的时候把status字段设置为1
	array (
			'created',
			'time',
			1,
			'function'
		)
		// 对create_time字段在更新的时候写入当前时间戳

	);
}
?>